"""author: wenyao
   data: 2021/11/5
   project: cjh
"""

#无序
#可变的
#看做一个只有key的字典
#  元素唯一，天生去重
#  可hash对象

#新增和删除
#add   update
#remove  discard
# >>> s1
# {1, 2, 3}
# >>> s1.add(4)
# >>> s1.update('ab')
# >>> s1
# {1, 2, 3, 4, 'b', 'a'}
# >>> s1.update({"c":1,"d":3})
# >>> s1
# {'d', 1, 2, 3, 4, 'c', 'b', 'a'}
# >>> s1.update({"c":1,"d":3}.items())
# >>> s1
# {'d', 1, 2, 3, 4, 'c', 'b', 'a', ('d', 3), ('c', 1)}
# >>> s1.remove('b')
# >>> s1
# {'d', 1, 2, 3, 4, 'c', 'a', ('d', 3), ('c', 1)}
# >>> s1.remove('a')
# >>> s1.remove('x')
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# KeyError: 'x'
# >>> s1.discard("x")
# >>> s1.discard(2)
# >>> s1
# {'d', 1, 3, 4, 'c', ('d', 3), ('c', 1)}

#######集合 并集 交集 差集 对称差集
# >>> s1 = {1,2,3,4,5,6}
# >>> s2 = {3,5,7,8,9,10}
# >>> s1
# {1, 2, 3, 4, 5, 6}
# >>> s2
# {3, 5, 7, 8, 9, 10}
# >>> s1 & s2
# {3, 5}
# >>> s1 | s2
# {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
# >>> s1 -s 2
#   File "<stdin>", line 1
#     s1 -s 2
#           ^
# SyntaxError: invalid syntax
# >>> s1 -s2
# {1, 2, 4, 6}
# >>> s1 ^ s2
# {1, 2, 4, 6, 7, 8, 9, 10}
